$(function() {
    initGalleryBox();
    setTimeout(processAdvs, 200);
});

function processAdvs() {
    var contentHeight = $('.main_column').height();
    var columnHeight = $('.column-right').height();
    var oldColumnHeight = columnHeight;
    while(columnHeight >= contentHeight + 150) {
        $('.column-right .adv-column .adv_thumbnail:last').remove();
        oldColumnHeight = columnHeight;
        columnHeight = $('.column-right').height();
        if(Math.abs(oldColumnHeight - columnHeight) <= 10) {
            break;
        }
    }
    columnHeight = $('.column-left').height();
    while(columnHeight >= contentHeight + 200) {
//        if($('.column-left .adv-column .adv_thumbnail').length <= 1) {
//            break;
//        }
        $('.column-left .adv-column .adv_thumbnail:last').remove();
        oldColumnHeight = columnHeight;
        columnHeight = $('.column-left').height();
        if(Math.abs(oldColumnHeight - columnHeight) <= 10) {
            break;
        }
    }
}

function initGalleryBox() {
    $('a.imagePreview').prettyPhoto({
        social_tools: ''
    });
}